package com.letoken.platform.admin.controller;

import com.letoken.platform.pub.annotation.auth.Permission;
import com.letoken.platform.pub.res.ApiResponse;
import com.letoken.platform.repo.app.dao.RedEnvelopeConfigMapper;
import com.letoken.platform.repo.app.po.RedEnvelopeConfig;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/red_envelope/config")
public class RedEnvelopeConfigController {

    @Resource
    private RedEnvelopeConfigMapper redEnvelopeConfigMapper;


    @Permission(uri = "/red_envelope/config/list" ,qx = "/red_envelope/config/list")
    @GetMapping("/list")
    public ApiResponse list() {
        return ApiResponse.create(redEnvelopeConfigMapper.list());
    }

    @Permission(uri = "/red_envelope/config/update" ,qx = "/red_envelope/config/update")
    @PostMapping("/update")
    public ApiResponse update(@RequestBody RedEnvelopeConfig redEnvelopeConfig) {
        redEnvelopeConfigMapper.updateByType(redEnvelopeConfig.getType(), redEnvelopeConfig.getMaximumTimesPerDay(), redEnvelopeConfig.getMaximumDailyAmount());
        return ApiResponse.create();
    }
}
